package org.zhuxian.cn.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zhuxian.cn.result.JsonResult;
import org.zhuxian.cn.utils.JwtUtils;

@RestController
@RequestMapping("/admin")
@Api(tags = "管理员功能", description = "管理员相关接口")
public class AdminController {

    @ApiOperation(value = "强制所有用户重新登录", notes = "使所有已登录用户的token失效，强制他们重新登录")
    @PostMapping("/invalidate-all-tokens")
    public JsonResult invalidateAllTokens() {
        JwtUtils.invalidateAllTokens();
        return new JsonResult(200, "已成功使所有用户token失效，用户需要重新登录");
    }
}